package com.inspur.ourhis_afterend.Service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inspur.ourhis_afterend.Dao.RegisterOrderDao;
import com.inspur.ourhis_afterend.Service.DoctorAdviceService;
import com.inspur.ourhis_afterend.Service.RegisterOrderService;
import com.inspur.ourhis_afterend.Tools.PageAction;
import com.inspur.ourhis_afterend.mapper.RegisterOrderMapper;
import com.inspur.ourhis_afterend.model.DoctorAdvice;
import com.inspur.ourhis_afterend.model.RegisterOrder;
import com.inspur.ourhis_afterend.vo.RegisterOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RegisterOrderServiceImpl implements RegisterOrderService {
    @Autowired
    RegisterOrderMapper registerOrderMapper;
    @Resource
    DoctorAdviceService doctorAdviceService;
    @Resource
    RegisterOrderDao registerOrderDao;
    @Override
    public int insertSelective(RegisterOrder registerOrder) {
        int num =registerOrderMapper.insertSelective(registerOrder);
        DoctorAdvice doctorAdvice = new DoctorAdvice();
        registerOrder = registerOrderDao.selectById(registerOrder.getMemberid());
        doctorAdvice.setMemeberid(registerOrder.getMemberid());
        doctorAdvice.setRoid(registerOrder.getRoid());
        doctorAdvice.setDocid(registerOrder.getDocid());
        doctorAdvice.setStatus("0");//1为正常状态，0为删除状态
        doctorAdviceService.insert(doctorAdvice);
        return num;
    }

    @Override
    public IPage<RegisterOrderVo> selectReSelective(Integer roid, Integer memeberid, String deptName, String rotime, PageAction pageAction) {
        IPage<RegisterOrderVo> iPage = new Page<>(pageAction.getPageNo(), pageAction.getPageSize());
        return registerOrderMapper.selectReSelective(iPage, roid, memeberid, deptName, rotime);
    }

    @Override
    public int deleteByPrimaryKey(Integer roid) {
        return registerOrderMapper.deleteByPrimaryKey(roid);
    }
}
